package com.sky.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * addResourceHandler()里配置需要映射的文件夹，此处代表映射文件夹user下的所有资源。
 * addResourceLocations()配置文件夹在系统中的路径，使用绝对路径，格式为“file:你的路径”
 * 意思就是 以/user/**这样子形式的访问全部将映射到 绝对路径file:/home/shop/src/main/resources/static/user/去
 */
@Configuration
public class MyImgConfig implements WebMvcConfigurer {
    public static final String filePath = "E:/JAVASpring/nginx-1.26.1/html/sky/img/";

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/img/**")
                .addResourceLocations("file:" + filePath);

    }
}